﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace learncore2.Middleware
{
    public class AuthMiddleware
    {
        private readonly RequestDelegate _next;
        private readonly ILogger _logger;

        public AuthMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
        {
            _next = next;
            _logger = loggerFactory.CreateLogger<AllowCorsMiddleware>();
        }
        public async Task Invoke(HttpContext context)
        {
            Console.WriteLine("url:"+ context.Request.Path);
            _logger.LogWarning(JsonConvert.SerializeObject(URLPath.ConvertToUrlPath(context.Request.Path)));
            await _next.Invoke(context);
        }
    }
}
